package com.hsoft.zhxy.app.xtgl_02_01.controller;

import com.alibaba.fastjson.JSONObject;
import com.hsoft.zhxy.app.common.model.entity.JcqxYhjs;
import com.hsoft.zhxy.app.common.model.entity.JcqxYhjsmx;
import com.hsoft.zhxy.app.xtgl_02_01.model.query.JsglQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

import com.hsoft.zhxy.app.xtgl_02_01.service.JcqxJsService;
import com.hsoft.zhxy.app.common.model.entity.JcqxJs;

import java.util.Arrays;

@Api(tags = "xtgl_02_01 角色")
@Log4j2
@Validated
@RestController
@RequestMapping(value = "/xtgl_02_01/jcqxJs/", produces = "application/json;charset=UTF-8")
public class JcqxJsController {

    @Autowired
    private JcqxJsService jcqxJsService;

    @ApiOperation(value = "查询单条数据", notes = "查询单条数据")
    @GetMapping("findOne")
    public JSONObject findOne(JcqxJs jcqxJs) {
        return jcqxJsService.findOne(jcqxJs);
    }


    @ApiOperation(value = "查询列表数据", notes = "查询列表数据")
    @GetMapping("findList")
    public JSONObject findList(JcqxJs jcqxJs) {
        return jcqxJsService.findList(jcqxJs);
    }


    @ApiOperation(value = "查询分页列表数据", notes = "查询分页列表数据")
    @GetMapping("findListByPage")
    public JSONObject findListByPage(JcqxJs jcqxJs,
                                     @Valid @NotNull(message = "页码为空") long page,
                                     @Valid @NotNull(message = "分页行数为空") long pageSize) {
        return jcqxJsService.findListByPage(jcqxJs, page, pageSize);
    }


    @ApiOperation(value = "新增", notes = "新增")
    @PostMapping("add")
    public JSONObject add(@RequestBody @Valid JcqxJs jcqxJs) {
        return jcqxJsService.add(jcqxJs);
    }


    @ApiOperation(value = "修改", notes = "修改")
    @PostMapping("update")
    public JSONObject update(@RequestBody @Valid JcqxJs jcqxJs) {
        return jcqxJsService.update(jcqxJs);
    }

    @ApiOperation(value = "删除", notes = "删除")
    @PostMapping("delete")
    public JSONObject delete(@RequestBody @Valid JcqxJs jcqxJs) {
        return jcqxJsService.delete(jcqxJs);
    }

    @ApiOperation(value = "获取角色下的角色数量", notes = "获取角色下的角色数量")
    @GetMapping("findCountZycdjs")
    public JSONObject findCountZycdjs(JcqxJs jcqxJs) {
        return jcqxJsService.findCountZycdjs(jcqxJs);
    }

    @ApiOperation(value = "获取所有资源列表", notes = "获取所有资源列表")
    @GetMapping("findYyzylistAll")
    public JSONObject findYyzylistAll(JcqxJs jcqxJs) {
        return jcqxJsService.findYyzylistAll(jcqxJs);
    }

    @ApiOperation(value = "修改功能资源信息", notes = "修改功能资源信息")
    @PostMapping("updateJsxzy")
    public JSONObject updateJsxzy(@RequestBody String str) {
        return jcqxJsService.updateJsxzy(str);
    }

    @ApiOperation(value = "获取角色下用户列表", notes = "获取角色下用户列表")
    @GetMapping("findJsxyhlist")
    public JSONObject findJsxyhlist(JsglQuery jsglQuery) {
        return jcqxJsService.findJsxyhlist(jsglQuery);
    }

    @ApiOperation(value = "获取用户列表", notes = "获取用户列表")
    @GetMapping("findYhList")
    public JSONObject findYhList(JsglQuery jsglQuery) {
        return jcqxJsService.findYhList(jsglQuery);
    }

    @ApiOperation(value = "新增角色用户", notes = "新增角色用户")
    @PostMapping("addJsyh")
    public JSONObject addJsyh(@RequestBody JcqxYhjs yhjs) {
        return jcqxJsService.addJsyh(yhjs);
    }

    @ApiOperation(value = "删除角色用户", notes = "删除角色用户")
    @PostMapping("delJsyh")
    public JSONObject delJsyh(@RequestBody JcqxYhjs yhjs) {
        return jcqxJsService.delJsyh(yhjs);
    }

    @ApiOperation(value = "获取用户角色明细列表", notes = "获取用户角色明细列表")
    @GetMapping("findYhjsmxList")
    public JSONObject findYhjsmxList(JsglQuery jsglQuery) {
        return jcqxJsService.findYhjsmxList(jsglQuery);
    }

    @ApiOperation(value = "获取部门列表", notes = "获取部门列表")
    @GetMapping("findBmlist")
    public JSONObject findBmlist() {
        return jcqxJsService.findBmlist();
    }

    @ApiOperation(value = "用户是否在相应部门", notes = "用户是否在相应部门")
    @GetMapping("findYhbmCount")
    public JSONObject findYhbmCount(JsglQuery jsglQuery) {
        return jcqxJsService.findYhbmCount(jsglQuery);
    }

    @ApiOperation(value = "添加用户角色明细", notes = "添加用户角色明细")
    @PostMapping("addYhjsmx")
    public JSONObject addYhjsmx(@RequestBody JcqxYhjsmx yhjsmx) {
        return jcqxJsService.addYhjsmx(yhjsmx);
    }

    @ApiOperation(value = "删除用户角色明细", notes = "删除用户角色明细")
    @PostMapping("deleteYhjsmx")
    public JSONObject deleteYhjsmx(@RequestBody JcqxYhjsmx yhjsmx) {
        return jcqxJsService.deleteYhjsmx(yhjsmx);
    }

    @ApiOperation(value = "修改角色父节点", notes = "修改角色父节点")
    @PostMapping("updateFjsid")
    public JSONObject updateFjsid(@RequestBody JcqxJs jcqxJs) {
        return jcqxJsService.updateFjsid(jcqxJs);
    }
    // 各方法命名需要以 find、add、update、delete开头，遵循驼峰原则


}